<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='global-property-'>/**
</span> * @ignore
 * tree management utils
 * @author yiminghe@gmail.com
 */
KISSY.add(&quot;tree/tree-manager&quot;, function (S, Node, DelegateChildrenExtension) {
    var UA = S.UA,
        ie = S.Env.host.document.documentMode || UA.ie,
        Features = S.Features,
        Gesture = Node.Gesture,
        isTouchEventSupported = Features.isTouchEventSupported();

<span id='KISSY-Tree-Manager'>    /**
</span>     * Manage tree node for tree root
     * @class KISSY.Tree.Manager
     */
    function TreeManager() {
    }

    TreeManager.ATTRS = {
<span id='KISSY-Tree-Manager-cfg-showRootNode'>        /**
</span>         * Whether show root node.
         * Defaults to: true.
         * @cfg {Boolean} showRootNode
         */
<span id='global-property-showRootNode'>        /**
</span>         * @ignore
         */
        showRootNode: {
            value: true,
            view: 1
        },
<span id='KISSY-Tree-Manager-property-selectedItem'>        /**
</span>         * Current selected tree node.
         * @property {KISSY.Tree.Node} selectedItem
         * @readonly
         */
<span id='global-property-selectedItem'>        /**
</span>         * @ignore
         */
        selectedItem: {},

        // only root node is focusable
        focusable: {
            value: true
        },

        handleMouseEvents: {
            value: true
        }
    };

    S.augment(TreeManager, DelegateChildrenExtension, {
        isTree: 1,

        __bindUI: function () {
            var self = this,
                prefixCls = self.get('prefixCls'),
                delegateCls = prefixCls + 'tree-node',
                events = Gesture.tap;

            events += ' ';

            if (!isTouchEventSupported) {
                events += (ie &amp;&amp; ie &lt; 9 ? &quot;dblclick &quot; : &quot;&quot;);
            }

            self.$el.delegate(events, '.' + delegateCls,
                self.handleChildrenEvents, self);
        },

        // 单选
        '_onSetSelectedItem': function (n, ev) {
            // 仅用于排他性
            if (n &amp;&amp; ev.prevVal) {
                ev.prevVal.set(&quot;selected&quot;, false, {
                    data: {
                        byPassSetTreeSelectedItem: 1
                    }
                });
            }
        },

        '_onSetShowRootNode': function (v) {
            this.get(&quot;rowEl&quot;)[v ? &quot;show&quot; : &quot;hide&quot;]();
        }
    });

    return TreeManager;
}, {
    requires: [
        'node',
        'component/extension/delegate-children'
    ]
});</pre>
</body>
</html>
